package ScratchPad
{
	import SplineComponent.SplineComponentModel;

	public class ScratchPadModel extends SplineComponentModel
	{
		private var scratchPadView:ScratchPadView;
        private var scratchPadController:ScratchPadController;
        private var syncStatus:Boolean;
        private var lessonModel:Object;
		
		public function ScratchPadModel(lessonModel:Object, lessonView:Object, lessonPath:String, lessonEditMode:Boolean)
		{
			super();
			this.lessonModel=lessonModel;
		scratchPadController=new ScratchPadController(this);
       	scratchPadView=new ScratchPadView(this,scratchPadController,lessonView,lessonEditMode);
       	this.addObserver(this.scratchPadView)
		}
	 
	   	private function SetEditModeStatus(Status:Boolean)
       	{
       		
       	}
       	private function SetTime(time:uint)
       	{
       	    if(syncStatus==true)
         	{
       		
         	}	
       	}
       	private function setSyncStatus(Status:Boolean)
       	{
       		syncStatus=Status;
       	}
       	private function Maximize()
       	{
       		
       	}
       	private function SaveChanges()
       	{
       		
       	}
       	private function SynchronizeWithTime(time:uint)
       	{
        var infoObj:Object=new Object();
       	infoObj.message="syncLessonTimeWithComponent";
       	infoObj.time=time;
       	outgoingMessageGateway(infoObj);
       	}
       	private function Minimize()
       	{
       	var infoObj:Object=new Object();
       	infoObj.message="componentMinimize";
       	outgoingMessageGateway(infoObj);	
       	}
       	private function close()
       	{
       	var infoObj:Object=new Object();
       	infoObj.message="unregisterComponentModel";
       	outgoingMessageGateway(infoObj);
       	}
       	private function outgoingMessageGateway(infoObj:Object)
       	{
       		infoObj.Title="ScratchPad";
       		lessonModel.incomingMessageGateway(infoObj);
       	}
       	
       	
       	
       	//------------------------------------Communication Functions----------------------------------------------------------------//
		
	 public function incomingMessageGateway(infoObj:Object)
       {
       	switch(infoObj.message.toString())
       	{
       		case "SetEditModeStatus":{
       			                      SetEditModeStatus(infoObj.status);
       			                      break;
       		                         }
       		case "SetTime":{
       			            SetTime(infoObj.time);
       			            break;
       		                }
       		case "SetMaximize":
       		                  {
       		                  	Maximize();
       		                  	break;
       		                  }
       		case "SaveChanges":
       		                  {
       		                  	SaveChanges();
       		                  	break;
       		                  }
       		case "mouseUpEvent":
					trace("ScratchPadModel------->event:mouseup  infoObj.event :"+infoObj.event);
					this.setChanged();
					this.notifyObservers(infoObj);
					break;
       	}
       }	
    
	
		
	}
}